<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<%@include file="/WEB-INF/views/common/head.jsp"%>
<script src="/js/highcharts/highcharts.js"></script>
<script src="/js/highcharts/highcharts-3d.js"></script>
<script src="/js/highcharts/modules/exporting.js"></script>

<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	$(function(){
		$("button").on('click',function(){
			var url=$(this).data("url");
			if(url){
				$('#myModal').find(".modal-body").html("正在加载....");
				url +="?"+$("#domainForm").serialize();
				//alert(11111111);
				$(".modal-body").load(url);
				$('#myModal').modal({
					backdrop:false,
					keyboard:true,
					show:true
				});
			}
		});
	});
</script>
<title>PurchaseBillItem管理</title>
</head>
<body>
	<s:form id="domainForm" action="purchaseBillItem">
		<div class="main-content">
			<div class="breadcrumbs" id="breadcrumbs">
				<script type="text/javascript">
					try {
						ace.settings.check('breadcrumbs', 'fixed')
					} catch (e) {
					}
				</script>

				<ul class="breadcrumb">
					<li><i class="icon-home home-icon"></i> <a href="/main.action">主页</a>
					</li>

					<li><a href="#">组织机构模块</a></li>
					<li class="active">PurchaseBillItem &amp 管理</li>
				</ul>
			</div>

			<div class="page-content">
				<div class="page-header">
					交易时间从：
					<s:date name="baseQuery.beginDate" format="yyyy-MM-dd" var="bDate" />
					<s:date name="baseQuery.endDate" format="yyyy-MM-dd" var="eDate" />
					<s:textfield name="baseQuery.beginDate" value="%{bDate}"
						onclick="WdatePicker({maxDate:new Date()})" size="13"
						cssClass="Wdate" style="height:30px;" placeholder="开始时间" 
						/>
					到：
					<s:textfield name="baseQuery.endDate" value="%{eDate}"
						onclick="WdatePicker({maxDate:new Date()})" size="13"
						cssClass="Wdate" style="height:30px;" placeholder="结束时间" 
						/>
					状态：
					<s:select list="#{-2:'--请选择--',0:'待审',1:'已审',-1:'作废'}"
						name="baseQuery.status" onchange="javascript:$('#domainForm').submit();" />
					分组条件：
					<s:select list="#{-2:'--请选择--','o.bill.supplier.name':'供应商','o.bill.buyer.username':'采购员','month(o.bill.vdate)':'月份'}"
						name="baseQuery.groupBy" onchange="javascript:$('#domainForm').submit();" />
					
					<button type="button" onclick="$('#domainForm').submit();" class="btn btn-info">
						搜索 <i class="icon-search icon-on-right bigger-110"></i>
					</button>

					<button data-url="purchaseBillItem_chart1.action" class="btn btn-info" type="button">
						<i class="icon-on-right">3D饼图</i> 
					</button>
					
					<button data-url="purchaseBillItem_chart2.action" class="btn btn-info" type="button">
						<i class="icon-on-right">2D饼图</i> 
					</button>
					<div>
						<div class="row">
							<div class="col-xs-12">
								<div class="row">
									<div class="col-xs-12">
										<div class="table-responsive">
											<table id="sample-table-1"
												class="table table-striped table-bordered table-hover">
												<thead>
													<tr>		
														<th>明细ID</th>
														<th>供应商</th>
														<th>采购员</th>
														<th>产品名称</th>
														<th>产品类型</th>
														<th>交易时间</th>
														<th>采购价格</th>
														<th>采购数量</th>
														<th>小计</th>
														<th>状态</th>
													</tr>
												</thead>

												<tbody id="itemTbody">
													<s:iterator value="#list" var="objects">
														<tr>
															<td style="color: blue" colspan="10">
																${objects[0]}-${objects[1]}条记录
															</td>
														</tr>

														<s:set var="totalAmount" value="0" />
														<s:set var="totalNum" value="0" />
														<s:iterator value="findItems(#objects[0])">
															<tr>
																<td>${id}</td>
																<td>${bill.supplier.name}</td>
																<td>${bill.buyer.username}</td>
																<td>${product.name}</td>
																<td>${product.types.name}</td>
																<td>${bill.vdate}</td>
																<td>${price}</td>
																<td>${num}</td>
																<td>${amount}</td>
																<td><s:if test="bill.status==1">
																		<span class="label label-sm label-warning">已审</span>
																	</s:if> <s:elseif test="bill.status==-1">
																		<span class="label label-sm label-inverse arrowed-in"><s>作废</s></span>
																	</s:elseif> <s:else>
																		<span class="label label-sm label-success">待审</span>
																	</s:else></td>
															</tr>
															<s:set var="totalAmount" value="#totalAmount+amount" />
															<s:set var="totalNum" value="#totalNum+num" />
														</s:iterator>
														<tr style="color: red">
															<th colspan="7">总计</th>
															<th>${totalNum}</th>
															<th>${totalAmount}</th>
														</tr>
													</s:iterator>
												</tbody>
											</table>
										</div>
									</div>
								</div>
								<%@include file="/WEB-INF/views/common/page.jsp"%>

								<div class="hr hr-18 dotted hr-double"></div>
							</div>
						</div>

					</div>
				</div>
			</div>
	</s:form>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel" style="color: red">饼图展示</h4>
				</div>
				<div class="modal-body"></div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
</body>
</html>